<template>
  <div class="houtaiNav">
    <div>
      <img src="../../assets/imgs/login.png" alt />
    </div>
    <div>
      <span>xxxx主持人团队 后台管理</span>
    </div>
    <div class="nav_a" v-if="isshow">
      <router-link to="/login">登录</router-link>
    </div>
    <div class="nav_a" v-if="isshow2">
      你好，{{user}}
      <a @click="dengchuhoutai">退出</a>
    </div>
  </div>
</template>

<script>
export default {
  name: "HouTaiNav",
  data() {
    return {
      isshow: true,
      isshow2: false,
      user: ""
    };
  },
  mounted() {
    if (localStorage.getItem("token")) {
      this.isshow = false;
      this.isshow2 = true;
      this.user = localStorage.getItem("phone");
    }
  },
  methods: {
    dengchuhoutai() {
      this.$store.commit("LoginModule/clearToken");
      this.$store.commit("LoginModule/clearphone");

      localStorage.clear();
      localStorage.removeItem("phone");
      this.isshow = true;
      this.isshow2 = false;
    }
  }
};
</script>

<style lang="less" scoped>
.houtaiNav {
  width: 100%;
  height: 90px;
  background-color: #cccccc;
  padding: 0 200px;
  box-sizing: border-box;
  div {
    img {
      width: 120px;
      margin: 10px 30px;
    }
    float: left;
    line-height: 90px;
    span {
      font-size: 26px;
      color: #000;
      font-weight: 600;
    }
  }
  .nav_a {
    float: right;
    margin-right: 200px;
    a {
      color: #000;
      margin-left: 10px;
      cursor: pointer;
    }
  }
}
</style>